package WaiBao;

import java.util.Arrays;

public class TanHaiChuan {
    public static void main(String[] args) {
        String[] name = {"王圣安(班长)", "李兴艳(副班长)", "小李(学习委员)", "亦将为(体育委员)", "孙来沈", "王皓吟", "岳样样", "刘周星", "张顺谷", "周卓豪", "张淮升", "是当属",
                "王施与", "范骞", "周依依", "陆从风", "刘先发", "陈深", "张顺链", "严细化", "卢全西", "张宏", "陶成", "欧共借", "李彩早", "郭磊", "李星星", "卫龙",
                "王红莲", "谭海川(学生)"};//考生本人:谭海川(学生)
        int[] age = {21, 20, 21,22, 20, 21, 18, 21, 20, 20, 18, 18, 18, 21, 20, 19, 18, 18, 18, 18, 19, 19, 20, 20, 20, 19, 18, 21,22,19};//考生年龄：19


        double[] ping1 = {75, 78, 85, 81, 80, 79, 78, 85, 81, 74, 91, 87, 85, 74, 61, 78, 69, 69, 75, 88, 92, 91, 95, 85, 75, 74, 77, 84, 91, 96};
        double[] ping2 = {76, 85, 85, 84, 75, 71, 84, 79, 75, 80, 94, 67, 76, 85, 67, 62, 84, 69, 62, 75, 82, 71, 84, 87, 75, 84, 78, 75, 81, 95};
        double[] ping3 = {77, 80, 81, 75, 79, 99, 68, 89, 80, 60, 83, 87, 85, 65, 65, 68, 89, 67, 94, 83, 94, 81, 85, 85, 76, 84, 73, 81, 84, 95};


        double digu1;//代表每个学生的总分
        double digu2;//代表每个学生的平均分
        for (int i = 0; i < 30; i++) {
            digu1 = ping1[i] +ping2[i] +ping3[i];
            digu2 = (digu1 * 1.0) / 3;
            System.out.println(name[i] + "的总分为:" + digu1);
            System.out.println(name[i] + "的平均分为:" +digu2);
        }


        double pubg1 = 0,pubg2 = 0;
//        double[] arr = new double[30];
//        for (int i = 0; i < 30; i++) {
//            pubg1 = ping1[i] + ping2[i] + ping3[i];
//            pubg2  = (pubg1 * 1.0) / 3;
//            arr[i] = pubg2;
//        }
//
//        for (int i = 0; i < arr.length - 1; i++) {
//            for (int j = 0; j < arr.length - i - 1; j++) {
//                if (arr[j] < arr[j + 1]) {
//                    double tep = arr[j];
//                    arr[j] = arr[j + 1];
//                    arr[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(arr[i]);
//        }


        double duck1 = 0, duck2 = 0,duck3 = 0;//计算每门课的平均分
        double fish1 = 0, fish2 = 0,fish3 = 0;//计算每门课标准差
        double poop1 = 0, poop2 = 0,poop3 = 0;//计算每门课中位数
        double sum2 = 0;
        for (int i = 0; i < ping1.length; i++) {
            sum2+=ping1[i];
        }
        duck1 = (sum2*1.0)/30;
        System.out.println("农业设施及环境调控的班级平均分为:"+duck1);
        double Sum = 0;
        for (int i = 0; i < ping2.length; i++) {
            Sum+=ping2[i];
        }
        duck2 = (Sum*1.0)/30;
        System.out.println("农业设施设计与建造的班级平均分为:"+duck2);
        double sum = 0;
        for (int i = 0; i <ping3.length; i++) {
            sum+=ping3[i];
        }
        duck3 = (sum*1.0)/30;
        System.out.println("园艺植物设施栽培学的班级平均分为:"+duck3);



        double c1 = 0,c2 = 0,c3 = 0;
        for (int i = 0; i < ping1.length; i++) {
            c1+= (ping1[i] -duck1)*(ping1[i] - duck1);
        }
        fish1 = Math.sqrt(c1*1.0/30);
        System.out.println("农业设施及环境调控的班级标准差为:"+fish1);

        for (int i = 0; i < ping2.length; i++) {
            c2+= (ping2[i] -duck2)*(ping2[i] - duck2);
        }
        fish2 = Math.sqrt(c2*1.0/30);
        System.out.println("农业设施设计与建造的班级标准差为:"+fish2);

        for (int i = 0; i < ping3.length; i++) {
            c3+= (ping3[i] -duck3)*(ping3[i] - duck3);
        }
        fish3 = Math.sqrt(c3*1.0/30);
        System.out.println("园艺植物设施栽培学的班级标准差为:"+fish3);
////////
        Arrays.sort(ping1);
        Arrays.sort(ping2);
        Arrays.sort(ping3);
        poop1 =( ping1[15]+ping1[14])*1.0/2;
        poop2 =( ping2[15]+ping2[14])*1.0/2;
        poop3 =(ping3[15]+ping3[14])*1.0/2;
        System.out.println("农业设施及环境调控的中位数为:"+poop1);
        System.out.println("业设施设计与建造的中位数为:"+poop2);
        System.out.println("园艺植物设施栽培学的中位数为:"+poop3);





    }
}
